<?php

class Emms_Form_Admin_Resource extends HTech_Form
{
    protected $_primary  = 'ResourceId';
    
    public function __construct() 
    {
        parent::__construct();        
        
        $this->setName('Resource');
                
        $this->setAttrib('title', $this->translate("Resource form"));
        $this->setDescription($this->translate("Edit resource info"));
                
        $resourceId = new Zend_Form_Element_Hidden('ResourceId');
        
        $module = new Zend_Form_Element_Text('Module');
        $module->setLabel("Module")
            ->setAttrib('disabled','disabled')
            ->setIgnore(true);
        
        $controller = new Zend_Form_Element_Text('Controller');
        $controller->setLabel("Controller")
            ->setAttrib('disabled','disabled')
            ->setIgnore(true);
        
        $action = new Zend_Form_Element_Text('Action');
        $action->setLabel("Action")
            ->setAttrib('disabled','disabled')
            ->setIgnore(true);
        
        $public = new Zend_Form_Element_Select('Public');
        $public->setLabel("Public")                
            ->setAttrib('size','2')
            ->setRequired(true)
            ->addMultiOptions(array('Yes' => $this->translate("Yes"), 'No' => $this->translate("No")));
        
        $submit = new Zend_Form_Element_Submit('Submit');
        $submit->setLabel("Submit")
            ->addDecorator(new HTech_Form_Decorator_Button(array('type'=>'submit')));
                                
        $roleId = new Zend_Form_Element_Multiselect('LnkResourcesRoles');
        $roleId->setLabel("Roles")                
            ->setAttrib('size','15')
            ->setRequired(false)
            ->addMultiOptions($this->_db->fetchPairs('select RoleId, Role from roles'));   
        
        $this->addElements(array($module,$controller,$action,$public,$roleId,$submit,$resourceId));
    }
}